package com.rich.user.controller;

import com.rich.common.annotation.IngoreResponseAdvice;
import com.rich.common.entity.TbSuggest;
import com.rich.common.entity.TbUser;
import com.rich.common.result.CommonResponse;
import com.rich.common.result.ResultData;
import com.rich.user.service.SuggestService;
import com.rich.user.service.UserService;
import com.rich.user.vo.SuggestVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author minicoco
 * @version 1.0
 * @date 2021/8/18 18:44
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @Autowired
    private SuggestService suggestService;

    @IngoreResponseAdvice
    @PostMapping("/findById")
    public TbUser findById(@RequestBody Long uid) {
        return userService.findById(uid);
    }

    /**
     * 问题反馈列表
     *
     * @param suggestVo
     * @return
     */
    @PostMapping("/findSuggestAll")
    public ResultData findSuggestAll(@RequestBody SuggestVo suggestVo) {
        return suggestService.findSuggestAll(suggestVo);
    }

    /**
     * 发送问题反馈
     *
     * @param suggest
     * @return
     */
    @PostMapping("/sendSuggest")
    public CommonResponse sendSuggest(@RequestBody TbSuggest suggest) {
        return suggestService.sendSuggest(suggest);
    }

    /**
     * 修改问题解决状态
     * @param id
     * @param status
     */
    @PutMapping("/updSuggestStatusById/{id}/{status}")
    public void updSuggestStatusById(@PathVariable("id") Integer id,
                                     @PathVariable("status") Integer status) {
        suggestService.updSuggestStatusById(id,status);
    }

}
